﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Granite.Modeling;
using Granite.Modeling.Validators;
using Granite.Modeling.Internals;
using Granite.Commons.Metadata;

namespace LeadTracker.Entities
{

	[DataContract(Name = "Editor", Namespace = "http://granite.codeplex.com/LeadTracker", IsReference = true)]
	public class Editor : ChangeTrackingModelBase
	{
		public Editor() { }

		public Editor(IDictionary<string, object> fields)
		{
			Load(fields);
		}

		[DataMember]
		public int EditorKey
		{
			get { return GetOrDefault<int>("EditorKey"); }
			set { SetValue("EditorKey", value); }
		}

		[DataMember]
		[Required]
		[MaxLength(50)]
		public string UserName
		{
			get { return GetOrDefault<string>("UserName", ""); }
			set { SetValue("UserName", value); }
		}

		[DataMemberAttribute]
		[Required]
		[MaxLength(50)]
		public string FirstName
		{
			get { return GetOrDefault<string>("FirstName", ""); }
			set { SetValue("FirstName", value); }
		}

		[DataMemberAttribute]
		[Required]
		[MaxLength(50)]
		public string LastName
		{
			get { return GetOrDefault<string>("LastName", ""); }
			set { SetValue("LastName", value); }
		}

		[CalculatedField("FirstName,LastName")]
		public string FullName
		{
			get { return FirstName + " " + LastName; }
		}

		[DataMember]
		[Required]
		[MaxLength(254)]
		public string EmailAddress
		{
			get { return GetOrDefault<string>("EmailAddress", ""); }
			set { SetValue("EmailAddress", value); }
		}

		[DataMember]
		public bool IsEnabled
		{
			get { return GetOrDefault<bool>("IsEnabled", false); }
			set { SetValue("IsEnabled", value); }
		}


	}
}



